{extend name="public/base" /}
{block name="style_before"}
<link rel="stylesheet" href="__THEME__/default/view/admin/static/css/base.css?v={:time_version()}">
{/block}
{block name="style"}
<link rel="stylesheet" href="__THEME__/default/view/admin/static/css/module.css?v={:time_version()}">
<link rel="stylesheet" href="__THEME__/default/view/admin/static/css/default_color.css?v={:time_version()}">
{/block}

{block name="content-header"}
<!-- Content Header (Page header) -->
<div class="content-header">
	<div class="container-fluid">
		<div class="row mb-2">
			<div class="col-sm-6">
				<h1 class="m-0 text-dark">
					分类管理
				</h1>
			</div><!-- /.col -->
			<div class="col-sm-6">
				<ol class="breadcrumb float-sm-right">
					<li class="breadcrumb-item"><a href="{:Url('index/index')}">首页</a></li>
					<li class="breadcrumb-item active">分类管理</li>
				</ol>
			</div><!-- /.col -->
		</div><!-- /.row -->
	</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
{/block}

{block name="content-content"}
<!-- Main content -->
<section class="content">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-12">

				<!-- 表格列表 -->
				<div class="tb-unit posr">
					<div class="tb-unit-bar">
						<a class="btn" href="{:Url('add')}">新 增</a>
					</div>
					<div class="category">
						<div class="hd cf">
							<div class="fold">折叠</div>
							<div class="order">排序</div>
							<div class="order">发布</div>
							<div class="name">名称</div>
						</div>
						{:action('category/tree', array($tree))}
					</div>
				</div>
				<!-- /表格列表 -->
			</div>
	</div><!-- /.container-fluid -->
</section>
<!-- /.content -->

<!-- Main content -->
<!-- /.content -->
{/block}

{block name='script'}
<script src="__THEME__/default/view/admin/static/js/common.js?v={:time_version()}"></script>
<script type="text/javascript" charset="utf-8">
highlight_subnav('{:Url('index')}');
(function($){
	/* 分类展开收起 */
	$(".category dd").prev().find(".fold i").addClass("icon-unfold")
		.click(function(){
			var self = $(this);
			if(self.hasClass("icon-unfold")){
				self.closest("dt").next().slideUp("fast", function(){
					self.removeClass("icon-unfold").addClass("icon-fold");
				});
			} else {
				self.closest("dt").next().slideDown("fast", function(){
					self.removeClass("icon-fold").addClass("icon-unfold");
				});
			}
		});

	/* 三级分类删除新增按钮 */
	$(".category dd dd .add-sub").remove();

	/* 实时更新分类信息 */
	$(".category")
		.on("submit", "form", function(){
			var self = $(this);
			$.post(
					self.attr("action"),
					self.serialize(),
					function(data){
						/* 提示信息 */
						var name = data.status ? "success" : "error", msg;
						msg = self.find(".msg").addClass(name).text(data.msg)
							.css("display", "inline-block");
						setTimeout(function(){
							msg.fadeOut(function(){
								msg.text("").removeClass(name);
							});
						}, 1000);
					},
					"json"
				  );
			return false;
		})
	.on("focus","input",function(){
		$(this).data('param',$(this).closest("form").serialize());

	})
	.on("blur", "input", function(){
		if($(this).data('param')!=$(this).closest("form").serialize()){
			$(this).closest("form").submit();
		}
	});
})(jQuery);
</script>
{/block}
